var x=document.getElementById("demo");
geocoder = new google.maps.Geocoder();
var map;
var mapholder;
var infowindow = new google.maps.InfoWindow();
var marker;

function getLocation()
  {
  if (navigator.geolocation)
    {
    navigator.geolocation.getCurrentPosition(showPosition,showError);
    }
//  else{x.innerHTML="Geolocation is not supported by this browser.";}
  }

function showPosition(position)
  {
	lat=position.coords.latitude;
	lon=position.coords.longitude;
	latlon=new google.maps.LatLng(lat, lon)
	mapholder=document.getElementById('mapHolder')
	mapholder.style.height='100%';
	mapholder.style.width='100%';
	var myOptions={
			center:latlon,
			zoom:14,
			mapTypeId:google.maps.MapTypeId.ROADMAP,
			mapTypeControl:false,
			NavigationControlStyle:{DEFAULT:0,SMALL:1,ANDROID:2,ZOOM_PAN:3,um:4,Tl:5}
	};
	var map=new google.maps.Map(document.getElementById('mapHolder'),myOptions);
	var marker=new google.maps.Marker({position:latlon,map:map,title:"You are here!"});
  }

function codeLatLng(lat,lng) {
//	var input = ('-31.70465158215243, -54.4532880390625');
//    var latlngStr = input.split(',', 2);
//    var lat = parseFloat(latlngStr[0]);
//    var lng = parseFloat(latlngStr[1]);
    var latlng = new google.maps.LatLng(lat, lng);
    var mapOptions = {
    		zoom: 14,
            center: latlng,
            mapTypeId:google.maps.MapTypeId.ROADMAP,
            NavigationControlStyle:{DEFAULT:0,SMALL:1,ANDROID:2,ZOOM_PAN:3,um:4,Tl:5}
    }
    var map = new google.maps.Map(document.getElementById('mapHolder'), mapOptions);
    geocoder.geocode({'latLng': latlng}, function(results, status) {
      if (status == google.maps.GeocoderStatus.OK) {
        if (results[1]) {
          map.setZoom(14);
          marker = new google.maps.Marker({
              position: latlng,
              map: map
          });
          infowindow.setContent(results[1].formatted_address);
          infowindow.open(map, marker);
        } else {
          alert('No results found');
        }
      } else {
        alert('Geocoder failed due to: ' + status);
      }
    });
  }
